home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / fs / fsStat.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  24.3 KB  |  607 lines

  1. /*
  2.  * fsStat.h --
  3.  *
  4.  *    Declarations for the file system statistics.
  5.  *
  6.  *    Note: since all variables are counters, they are unsigned
  7.  *    in order to make the high-order bit useable.
  8.  *
  9.  * Copyright 1986 Regents of the University of California
  10.  * All rights reserved.
  11.  *
  12.  *
  13.  * $Header: /cdrom/src/kernel/Cvsroot/kernel/fs/fsStat.h,v 9.18 92/06/01 14:45:41 kupfer Exp $ SPRITE (Berkeley)
  14.  */
  15.  
  16. #ifndef _FSSTAT
  17. #define _FSSTAT
  18.  
  19. /*
  20.  * Note, both client and server Naming operations are kept.
  21.  */
  22. typedef struct Fs_NameOpStats {
  23.     unsigned int numReadOpens;        /* open(O_RDONLY) on client.  Count
  24.                      * of all server open calls */
  25.     unsigned int numWriteOpens;        /* open(O_WRONLY) */
  26.     unsigned int numReadWriteOpens;    /* open(O_RDWR) */
  27.     unsigned int chdirs;        /* Number Fs_ChangeDir */
  28.     unsigned int makeDevices;        /* Number Fs_MakeDevice */
  29.     unsigned int makeDirs;        /* Number Fs_MakeDirectory */
  30.     unsigned int removes;        /* Number Fs_Remove */
  31.     unsigned int removeDirs;        /* Number Fs_RemoveDirs */
  32.     unsigned int renames;        /* Number Fs_Rename */
  33.     unsigned int hardLinks;        /* Number Fs_HardLink */
  34.     unsigned int symLinks;        /* Number Fs_SymLink */
  35.     unsigned int getAttrs;        /* Number get attrs from name */
  36.     unsigned int setAttrs;        /* Number set attrs by name */
  37.     unsigned int getAttrIDs;        /* Number set attrs by open stream */
  38.     unsigned int setAttrIDs;        /* Number get attrs from open stream */
  39.     unsigned int getIOAttrs;        /* Number get attr from I/O server */
  40.     unsigned int setIOAttrs;        /* Number set attr to I/O server */
  41. } Fs_NameOpStats;
  42.  
  43. typedef struct Fs_GeneralStats {
  44.     unsigned int physBytesRead;        /* Number of physical (ie descriptors)
  45.                       * disk bytes read. */
  46.     unsigned int fileBytesRead;        /* Number of file bytes read from the
  47.                      * disk */
  48.     unsigned int fileReadOverflow;    /* Extra */
  49.     unsigned int remoteBytesRead;    /* Bytes read in Fsrmt_Read. */
  50.     unsigned int remoteReadOverflow;    /* Extra */
  51.     unsigned int deviceBytesRead;    /* Number of bytes read from devices */
  52.  
  53.     unsigned int physBytesWritten;    /* Number of physical disk bytes
  54.                      * written */
  55.     unsigned int fileBytesWritten;    /* Number of file bytes written to
  56.                      * the disk */
  57.     unsigned int fileWriteOverflow;    /* Extra */
  58.     unsigned int remoteBytesWritten;    /* Bytes written in Fsrmt_Write */
  59.     unsigned int remoteWriteOverflow;    /* Extra */
  60.     unsigned int deviceBytesWritten;    /* Number of bytes written to devices */
  61.     unsigned int fileBytesDeleted;    /* Number of file bytes deleted
  62.                      * (total) */
  63.     unsigned int fileDeleteOverflow;    /* Extra */
  64. } Fs_GeneralStats;
  65.  
  66. /*
  67.  * Cache statistics.
  68.  */
  69. typedef struct Fs_BlockCacheStats {
  70.     /*
  71.      * Read statistics.
  72.      */
  73.     unsigned int readAccesses;        /* Read fetches on the cache. */
  74.     unsigned int bytesRead;        /* Total bytes read from the cache
  75.                      * including misses read into cache
  76.                      * This doesn't include bytes read
  77.                      * after a failed swap page cache
  78.                      * access, since those bytes aren't
  79.                      * read into the cache. */
  80.     unsigned int bytesReadOverflow;    /* Extra */
  81.     unsigned int readHitsOnDirtyBlock;    /* Fetches that hit on a block that had
  82.                       * dirty data in it. */
  83.     unsigned int readHitsOnCleanBlock;    /* Fetches that hit on a block that had
  84.                       * clean data in it. */
  85.     unsigned int readZeroFills;        /* Blocks that are zero filled
  86.                      * because read did not fill the
  87.                      * whole block. */
  88.     unsigned int domainReadFails;    /* Number of domain reads from
  89.                      * Fscache_Write and Fscache_Read that
  90.                      * were unsuccessful. */
  91.     unsigned int readAheads;        /* Number of read ahead processes
  92.                      * that were started up. */
  93.     unsigned int readAheadHits;        /* Number of reads that hit on a
  94.                      * block that was read ahead. */
  95.     unsigned int allInCacheCalls;    /* Number of time FscacheAllBlocksInCache routine
  96.                      * was called. */
  97.     unsigned int allInCacheTrue;        /* Number of times that FscacheAllBlocksInCache
  98.                      * returned TRUE. */
  99.     /*
  100.      * Write statistics.  See also WriteBackStats.
  101.      */
  102.     unsigned int writeAccesses;        /* Number of write fetches on the
  103.                      * cache. */
  104.     unsigned int bytesWritten;        /* Total bytes written to the cache
  105.                      * including new blocks */
  106.     unsigned int bytesWrittenOverflow;    /* Extra */
  107.     unsigned int appendWrites;        /* NEVER SET. Blocks written in 
  108.                      * append mode. */
  109.     unsigned int overWrites;        /* Cache blocks that were
  110.                      * overwritten. */
  111.     unsigned int writeZeroFills1;    /* Blocks that are zero filled because
  112.                      * read of old block did not fill
  113.                      * whole block. */
  114.     unsigned int writeZeroFills2;    /* Blocks that are zero filled because
  115.                      * user is only doing a partial write
  116.                      * to a new block. */
  117.     unsigned int partialWriteHits;    /* Read hits in the cache when are
  118.                      * writing to the middle of a block
  119.                      * and have to read in the data that
  120.                      * is already there. */
  121.     unsigned int partialWriteMisses;    /* Misses for above case. */
  122.     unsigned int blocksWrittenThru;    /* Number of dirty blocks that were
  123.                      * written thru. */
  124.     unsigned int dataBlocksWrittenThru;    /* Number of data block that were
  125.                      * written thru. */
  126.     unsigned int indBlocksWrittenThru;    /* Number of indirect blocks that
  127.                      * were written thru. */
  128.     unsigned int descBlocksWrittenThru;    /* Number of descriptor blocks that
  129.                      * were written thru. */
  130.     unsigned int dirBlocksWrittenThru;    /* Number of directory blocks that
  131.                      * were writtenw thru. */
  132.     /*
  133.      * Fragment statistics.
  134.      */
  135.     unsigned int fragAccesses;        /* Cache blocks that were fetched in
  136.                      * order to upgrade fragments. */
  137.     unsigned int fragHits;        /* Hits on fragAccesses. */
  138.     unsigned int fragZeroFills;        /* Cache blocks that had to be zero
  139.                      * filled because of frag upgrades. */
  140.     /*
  141.      * File descriptor accesses.
  142.      */
  143.     unsigned int fileDescReads;        /* File descriptor reads. */
  144.     unsigned int fileDescReadHits;    /* File descriptor hits in the cache. */
  145.     unsigned int fileDescWrites;    /* File descriptor writes. */
  146.     unsigned int fileDescWriteHits;    /* File descriptor write hits in the
  147.                      * cache. */
  148.     /*
  149.      * Indirect block accesses.
  150.      */
  151.     unsigned int indBlockAccesses;    /* Indirect block reads. */
  152.     unsigned int indBlockHits;        /* Access hits in the cache. */
  153.     unsigned int indBlockWrites;    /* Indirect blocks written. */
  154.     /*
  155.      * Directory block accesses.
  156.      */
  157.     unsigned int dirBlockAccesses;    /* Directory block reads. */
  158.     unsigned int dirBlockHits;        /* Directory block hits. */
  159.     unsigned int dirBlockWrites;    /* Directory block writes. */
  160.     unsigned int dirBytesRead;        /* Bytes read from directories */
  161.     unsigned int dirBytesWritten;    /* Bytes written to directories */
  162.     /*
  163.      * Variable size cache statistics.
  164.      */
  165.     unsigned int vmRequests;        /* Number of times virtual memory
  166.                      * requested memory from us. */
  167.     unsigned int triedToGiveToVM;    /* Number of vmRequests that we
  168.                      * tried to satisfy because
  169.                      * we had free blocks */
  170.     unsigned int vmGotPage;        /* Number of vmRequests that we
  171.                      * satisfied after checking LRU times */
  172.     /*
  173.      * Block allocation statistics.
  174.      */
  175.     unsigned int partFree;        /* Got the block off of the partially
  176.                      * free list. */
  177.     unsigned int totFree;        /* Got the block off of the totally
  178.                      * free list. */
  179.     unsigned int unmapped;        /* Created a new block. */
  180.     unsigned int lru;                /* Recycled a block. */
  181.     /*
  182.      * Cache size numbers.  These are monitored data, not counters--don't
  183.      * reset them.
  184.      */
  185.     unsigned int minCacheBlocks;    /* The minimum number of blocks that
  186.                       * can be in the cache. */
  187.     unsigned int maxCacheBlocks;    /* The maximum number of blocks that
  188.                       * can be in the cache. */
  189.     unsigned int maxNumBlocks;        /* The maximum number of blocks that
  190.                      * can ever be in the cache. */
  191.     unsigned int numCacheBlocks;    /* The actual number of blocks that
  192.                      * are in the cache. */
  193.     unsigned int numFreeBlocks;        /* The number of cache blocks that
  194.                      * aren't being used. */
  195.     /*
  196.      * Miscellaneous.
  197.      */
  198.     unsigned int blocksPitched;        /* The number of blocks thrown
  199.                      * out because they duplicated
  200.                      * VM-managed blocks. */
  201.     int blocksFlushed;            /* The number of blocks written back
  202.                        due to consistency. */
  203.     int migBlocksFlushed;        /* The number of blocks written back
  204.                        due to consistency for migrated
  205.                        files. */
  206. } Fs_BlockCacheStats;
  207.  
  208. /*
  209.  * Block allocation statistics.
  210.  */
  211. typedef struct Fs_AllocStats {
  212.     unsigned int blocksAllocated;    /* Full blocks allocated. */
  213.     unsigned int blocksFreed;        /* Full blocks freed. */
  214.     unsigned int cylsSearched;        /* Cylinders searched to find a good
  215.                      * cylinder.*/
  216.     unsigned int cylHashes;        /* Hashes done to find a starting
  217.                      * cylinder. */
  218.     unsigned int cylBitmapSearches;    /* Cylinder bitmap entries searched. */
  219.     unsigned int fragsAllocated;    /* Fragments allocated. */
  220.     unsigned int fragsFreed;        /* Fragments freed. */
  221.     unsigned int fragToBlock;        /* Fragments that when freed made a
  222.                      * full block free. */
  223.     unsigned int fragUpgrades;        /* Fragments that were attempted to
  224.                      * be extended.*/
  225.     unsigned int fragsUpgraded;        /* Number of fragUpgrades that
  226.                      * were successful. */
  227.     unsigned int badFragList;        /* Fragment list entries that didn't
  228.                      * really have fragments of the
  229.                      * desired size.*/
  230.     unsigned int fullBlockFrags;    /* Full blocks that had to
  231.                      * be fragmented. */
  232. } Fs_AllocStats;
  233.  
  234. /*
  235.  * Name cache statistics.
  236.  */
  237. typedef struct Fs_NameCacheStats {
  238.     unsigned int accesses;        /* Number of times something was
  239.                      * looked for */
  240.     unsigned int hits;            /* Number of times it was found */
  241.     unsigned int replacements;        /* Number of entries recycled via LRU */
  242.     unsigned int size;            /* Number of entries total */
  243. } Fs_NameCacheStats;
  244.  
  245. /*
  246.  * Handle statistics.
  247.  */
  248. typedef struct Fs_HandleStats {
  249.     unsigned int maxNumber;    /* Current limit on table size. */
  250.     unsigned int exists;    /* Number of handles currently in existence. */
  251.     unsigned int installCalls;    /* Calls to Fsutil_HandleInstall. */
  252.     unsigned int installHits;    /* installs in which handle was found. */
  253.     unsigned int fetchCalls;    /* Calls to Fsutil_HandleFetch. */
  254.     unsigned int fetchHits;    /* fetches in which handle was found. */
  255.     unsigned int release;    /* Calls to Fsutil_HandleRelease. */
  256.     unsigned int locks;        /* Number of times a handle was locked. */
  257.     unsigned int lockWaits;    /* Number of times had to wait on a lock */
  258.     unsigned int unlocks;    /* Number of times a handle was unlocked. */
  259.     unsigned int created;    /* Handles that have been created. */
  260.     unsigned int lruScans;    /* Number of LRU replacement scans */
  261.     unsigned int lruChecks;    /* Number of handles checked for reclaimation */
  262.     unsigned int lruHits;    /* Number of handles actually reclaimed */
  263.     unsigned int lruEntries;    /* Number of handles in LRU list. */
  264.     unsigned int limbo;        /* Number of handles marked for removal */
  265.     /*
  266.      * The following are specific to regular files.
  267.      */
  268.     unsigned int versionMismatch; /* Version mismatch on file. */
  269.     unsigned int cacheFlushes;    /* Cache flushed because of version mismatch
  270.                  * of not cacheable. */
  271.     unsigned int segmentFetches; /* Calls by VM to see if there is indeed
  272.                   * already a segment with the code file. */
  273.     unsigned int segmentHits;    /* Segment fetches that return non-nil
  274.                  * segment. */
  275. } Fs_HandleStats;
  276.  
  277. /*
  278.  * Prefix table statistics.  These are client-side statistics
  279.  */
  280. typedef struct Fs_PrefixStats {
  281.     unsigned int relative;    /* Number of relative names encountered */
  282.     unsigned int absolute;    /* Number of absolute names subject to prefix
  283.                  * lookup */
  284.     unsigned int redirects;    /* Number of redirects from the server */
  285.     unsigned int loops;        /* Number of circular redirects */
  286.     unsigned int timeouts;    /* Number of times the server was down */
  287.     unsigned int stale;        /* Number of times server server rejected a
  288.                  * handle */
  289.     unsigned int found;        /* Number of times found a new prefix */
  290. } Fs_PrefixStats;
  291.  
  292. /*
  293.  * Name lookup statistics.  These are server-side statistics.
  294.  */
  295. typedef struct Fs_LookupStats {
  296.     unsigned int number;    /* Number of pathname lookups */
  297.     unsigned int numComponents;    /* Number of pathname components parsed */
  298.     unsigned int numSpecial;    /* Number of $MACHINE names encounted */
  299.     unsigned int forDelete;    /* Number for deletion */
  300.     unsigned int forLink;    /* Number for linking */
  301.     unsigned int forRename;    /* Number for rename */
  302.     unsigned int forCreate;    /* Number for creation */
  303.     unsigned int symlinks;    /* Number of symbolic links encountered */
  304.     unsigned int redirect;    /* Number of redirects due to symbolic links */
  305.     unsigned int remote;    /* Number of redirects due to remote links */
  306.     unsigned int parent;    /* Number of redirects due to ".." */
  307.     unsigned int notFound;    /* Number of FILE_NOT_FOUND lookups */
  308. } Fs_LookupStats;
  309.  
  310. /*
  311.  * Counts of various file system objects.
  312.  */
  313. typedef struct Fs_ObjectStats {
  314.     int streams;
  315.     int streamClients;        /* Equal to streams, except during migration */
  316.     int files;            /* Local files, not including directories */
  317.     int rmtFiles;
  318.     int pipes;
  319.     int devices;
  320.     int controls;        /* Pdev and Pfs control streams */
  321.     int pseudoStreams;        /* One count for both client/server handles */
  322.     int remote;            /* All the various remote objects but files*/
  323.     int directory;
  324.     int dirFlushed;        /* Directories that were flushed */
  325.     int fileClients;        /* Number of consist.clientList entries */
  326.     int other;            /* For unknown objects */
  327. } Fs_ObjectStats;
  328.  
  329. /*
  330.  * File system recovery statistics.
  331.  */
  332. typedef struct Fs_RecoveryStats {
  333.     int number;            /* Number of reopens by this client */
  334.     int wants;            /* Calls to Fsutil_WantRecovery */
  335.     int waitOK;            /* Successful RecoveryWaits */
  336.     int waitFailed;        /* Unnsuccessful RecoveryWaits */
  337.     int waitAbort;        /* Interrupted RecoveryWaits */
  338.     int timeout;        /* Re-open's that timed out */
  339.     int failed;            /* Re-open's that failed */
  340.     int deleted;        /* Re-open's of a file that has been deleted */
  341.     int offline;        /* Re-open's of a file that is now offline */
  342.     int succeeded;        /* Re-open's that worked */
  343.     int clientCrashed;        /* Number of clients that crashed */
  344.     int clientRecovered;    /* Number of clients that re-opened files */
  345.     int    reopensAvoided;        /* Unneeded reopens skipped */
  346. } Fs_RecoveryStats;
  347.  
  348. /*
  349.  * Cache conistency statistics.
  350.  */
  351. typedef struct Fs_ConsistStats {
  352.     int files;            /* The number of times consistency was checked*/
  353.     int clients;        /* The number of clients considered */
  354.     int notCaching;        /* # of other clients that weren't caching */
  355.     int readCachingMyself;    /* # of clients that were read caching */
  356.     int readCachingOther;    /* # of other clients that were read caching */
  357.     int writeCaching;        /* # of lastWriters that re-opened  */
  358.     int writeBack;        /* # of lastWriters forced to write-back */
  359.     int readInvalidate;        /* # of readers forced to stop caching */
  360.     int writeInvalidate;    /* # of writers forced to stop caching */
  361.     int nonFiles;        /* # of directories, links, etc. */
  362.     int swap;            /* # of uncached swap files. */
  363.     int cacheable;        /* # of files that were cacheable */
  364.     int uncacheable;        /* # of files that were not cacheable */
  365. } Fs_ConsistStats;
  366.  
  367. /*
  368.  * (More) Write-back statistics.
  369.  */
  370. typedef struct Fs_WriteBackStats {
  371.     int passes;            /* Number of times Fs_CleanBlocks called */
  372.     int files;            /* Number of dirty files processed */
  373.     int blocks;            /* Number of dirty blocks processed */
  374.     int maxBlocks;        /* Max blocks processed in one pass */
  375. } Fs_WriteBackStats;
  376.  
  377. /*
  378.  * Some miscellaneous stats to determine why we read remote bytes.
  379.  */
  380. typedef struct Fs_RemoteIOStats {
  381.     int blocksReadForVM;    /* Blocks read from Fs_PageRead (old) */
  382.     int bytesReadForCache;    /* Bytes read into the cache for remote files */
  383.     int bytesWrittenFromCache;    /* Bytes written from the cache for rmt files */
  384.     int uncacheableBytesRead;    /* Uncacheable bytes read (not counting swap) *
  385.                     * (FS_NOT_CACHEABLE flag) */
  386.     int uncacheableBytesWritten;/* Uncacheable bytes written *
  387.                     * (FS_NOT_CACHEABLE flag) */
  388.     int sharedStreamBytesRead;    /* Bytes read from shared uncacheable streams */
  389.     int sharedStreamBytesWritten;/* Bytes written to shared uncached streams */
  390.     int hitsOnVMBlock;        /* Code and Heap pages found in the cache */
  391.     int missesOnVMBlock;    /* This shoudl be code and heap pages not found
  392.                  * in the cache, but it includes the misses
  393.                  * due to stupid swap page cache accesses.  We
  394.                  * will almost never find those, unless they
  395.                  * are due to a shared page.  So subtract the
  396.                  * number of swap page misses from this to get
  397.                  * a more reasonable value. */
  398. /* We really need a counter for shared page accesses and hits. */
  399.     int bytesReadForVM;        /* Bytes read in RmtFilePageRead */
  400.     int bytesWrittenForVM;    /* Bytes written in RmtFilePageWrite */
  401.     int    hitsOnHeapBlock;    /* Block in cache. */
  402.     int    missesOnHeapBlock;    /* Block not in cache. */
  403.     int    hitsOnCodePage;        /* Block in cache. */
  404.     int    missesOnCodePage;    /* Block not in cache. */
  405.     int    hitsOnSwapPage;        /* Block in cache.  This should be very rare
  406.                  * since it would only be if the "swap" page
  407.                  * is actually a shared page. */
  408.     int    missesOnSwapPage;    /* Block not in cache.  This will be the norn.
  409.                  * Subtract this value from missesOnVMBlock in
  410.                  * order to get the reasonable number of vm
  411.                  * cache misses.  We look in the cache for
  412.                  * all swap pages, and will only find shared
  413.                  * pages. */
  414.     int    bytesReadForHeap;        /* Heap bytes read into cache */
  415.     int    bytesReadForHeapUncached;    /* Uncached heap bytes read.  This
  416.                      * should almost always be zero, since
  417.                      * it's only upon an error that
  418.                      * heap blocks can't be read into
  419.                      * the cache. */
  420.     int    uncacheableDirBytesRead;    /* Directory bytes remotely read are
  421.                      * not cacheable. */
  422.     int    remoteDevicishBytesRead;    /* Device-like bytes read remotely.
  423.                      * This includes devices, pipes,
  424.                      * pseudo devices, pseudo file systems
  425.                      * and their control streams.  It
  426.                      * only includes successful bytes
  427.                      * read. */
  428.     int    remoteDevicishBytesWritten;    /* Devicish bytes written remotely.
  429.                      * This includes devices, pipes,
  430.                      * pseudo devices, pseudo file systems
  431.                      * and their control streams.  It
  432.                      * only includes successful bytes
  433.                      * written. */
  434.                     
  435.  
  436. } Fs_RemoteIOStats;
  437.  
  438. /*
  439.  * Statistics relating to migration.
  440.  */
  441. typedef struct Fs_MigStats {
  442.     unsigned int filesEncapsulated;     /* Total number of files encapsulated
  443.                        by this host */
  444.     unsigned int filesDeencapsulated;     /* Total number of files deencapsulated
  445.                        by this host */
  446.     unsigned int consistActions;     /* Total number of files for which
  447.                        this host was the i/o server doing
  448.                        consistency */
  449.     unsigned int readOnlyFiles;     /* Total number of files deencapsulated
  450.                        read-only */
  451.     unsigned int alreadyThere;         /* Total number of (writable) files
  452.                        already on target. NOT USED. */
  453.     unsigned int uncacheableFiles;     /* Total number of files deencapsulated
  454.                        that were uncacheable to begin
  455.                        with, and stayed that way. */
  456.     unsigned int cacheWritableFiles;     /* Total number of cacheable, writable
  457.                        files that were still cacheable
  458.                        after migration. */
  459.     unsigned int uncacheToCacheFiles;     /* Total number of uncacheable
  460.                        files that became cacheable after
  461.                        migration. */
  462.     unsigned int cacheToUncacheFiles;     /* Total number of cacheable
  463.                        files that became uncacheable after
  464.                        migration. */
  465.     unsigned int errorsOnDeencap;    /* Any files that couldn't be
  466.                        deencapsulated due to errors. */
  467.     unsigned int encapSquared;         /* Sum of squares for
  468.                        filesEncapsulated. */
  469.     unsigned int deencapSquared;     /* Sum of squares for
  470.                        filesDeencapsulated. */
  471. } Fs_MigStats;
  472.  
  473. /*
  474.  * File system statistics.  If you change this struct, be sure to verify 
  475.  * that ZeroFsStats is still okay.
  476.  */
  477. #define FS_STAT_VERSION 2
  478. typedef struct Fs_Stats {
  479.     int            statsVersion;   /* Version number of statistics info */
  480.     Fs_NameOpStats    cltName;    /* Client-side naming operations */
  481.     Fs_NameOpStats    srvName;    /* Server-side naming operations */
  482.     Fs_GeneralStats    gen;        /* General I/O operations */
  483.     Fs_BlockCacheStats    blockCache;    /* Block cache operations */
  484.     Fs_AllocStats    alloc;        /* Disk allocation */
  485.     Fs_HandleStats    handle;        /* Handle management */
  486.     Fs_PrefixStats    prefix;        /* Client-side prefix operations */
  487.     Fs_LookupStats    lookup;        /* Server-side lookup operations */
  488.     Fs_NameCacheStats    nameCache;    /* Server name cache */
  489.     Fs_ObjectStats    object;        /* Counts of various objects */
  490.     Fs_RecoveryStats    recovery;    /* Crash recovery and reopening */
  491.     Fs_ConsistStats    consist;    /* Cache consistency actions */
  492.     Fs_WriteBackStats    writeBack;    /* Cache write-back stats */
  493.     Fs_RemoteIOStats    rmtIO;        /* Remote I/O stats */
  494.     Fs_MigStats        mig;        /* Migration */
  495. } Fs_Stats;
  496.  
  497. /*
  498.  * Keep a histogram of file lifetimes in a three-dimensional matrix,
  499.  * for lifetime, file size, and file type.  Buckets for size are
  500.  * scaled logarithmically.  Buckets for lifetime are determined as
  501.  * follows, where each bucket corresponds to a lifetime less than that
  502.  * value:
  503.  *
  504.  *    seconds: 1, 2, ..., 10, 20, ..., 50
  505.  *    minutes: 1, 2, ..., 10, 20, ..., 50
  506.  *      hours:   1, 2, ..., 10, 15, 20 (<24)
  507.  *    days:    1, 2, ..., 10, 20, .., 60, 90, 120, 180, 240, 300, 360, > 360
  508.  *
  509.  * For example, a file that is 0 seconds old is < 1 second and is in
  510.  * bucket 0; a file that is exactly 15 hours old is in the bucket labeled
  511.  * "20 hours" since that contains everything from 15 hours to
  512.  * (20 hours - 1 second).
  513.  *
  514.  * The divisions are somewhat arbitrary and are subject to change.
  515.  * Define the number of buckets here: 32 size buckets will cover 2 **
  516.  * 32 bytes (max file size); throw in one more bucket for subtotals by
  517.  * time.  For times, define an array containing the number of seconds
  518.  * and number of buckets for each group described above.
  519.  */
  520. #define FS_HIST_SIZE_BUCKETS     33
  521.  
  522. typedef struct Fs_HistGroupInfo {
  523.     unsigned int secondsPerBucket;
  524.     unsigned int bucketsPerGroup;
  525. } Fs_HistGroupInfo;
  526.  
  527.  
  528. #define FS_HIST_SECONDS        10
  529. #define FS_HIST_TEN_SECONDS    5
  530. #define FS_HIST_MINUTES        9
  531. #define FS_HIST_TEN_MINUTES    5
  532. #define FS_HIST_HOURS        9
  533. #define FS_HIST_FIVE_HOURS    2
  534. #define FS_HIST_REST_HOURS    1
  535. #define FS_HIST_DAYS        9
  536. #define FS_HIST_TEN_DAYS     5
  537. #define FS_HIST_THIRTY_DAYS     2
  538. #define FS_HIST_SIXTY_DAYS     4
  539. #define FS_HIST_REST_DAYS     1
  540.  
  541. #define FS_HIST_TIME_BUCKETS (FS_HIST_SECONDS + \
  542.                   FS_HIST_TEN_SECONDS + \
  543.                   FS_HIST_MINUTES + \
  544.                   FS_HIST_TEN_MINUTES + \
  545.                   FS_HIST_HOURS + \
  546.                   FS_HIST_FIVE_HOURS + \
  547.                   FS_HIST_REST_HOURS + \
  548.                   FS_HIST_DAYS + \
  549.                   FS_HIST_TEN_DAYS + \
  550.                   FS_HIST_THIRTY_DAYS + \
  551.                   FS_HIST_SIXTY_DAYS + \
  552.                   FS_HIST_REST_DAYS)
  553.  
  554. /*
  555.  * The number of types that we gather statistics for.
  556.  */
  557. #define FS_STAT_NUM_TYPES 5
  558.  
  559. /*
  560.  * Subscripts for arrays that separate data for read and write.
  561.  */
  562. #define FS_STAT_READ 0
  563. #define FS_STAT_WRITE 1
  564.  
  565. typedef struct Fs_TypeStats {
  566.     unsigned int diskBytes[2][FS_STAT_NUM_TYPES];
  567.                     /* Number of bytes read/written from/to
  568.                  * different types of files on disk */
  569.     unsigned int cacheBytes[2][FS_STAT_NUM_TYPES];
  570.                     /* Number of bytes read or written through
  571.                  * cache */
  572.     unsigned int bytesDeleted[FS_STAT_NUM_TYPES];
  573.                     /* Number of bytes deleted from files due
  574.                  * to truncation or removal */
  575.     unsigned int deleteHist    /* Histogram of deletions, by type */
  576.         [FS_HIST_TIME_BUCKETS] [FS_HIST_SIZE_BUCKETS] [FS_STAT_NUM_TYPES];
  577. } Fs_TypeStats;
  578.  
  579. Fs_TypeStats fs_TypeStats;
  580.  
  581. /*
  582.  * Macro to add to a counter, watching for overflow.  We use unsigned
  583.  * integers and wrap around if the high-order bit gets set.  This assumes
  584.  * that the amount to be added each time is
  585.  * relatively small (so we can't miss the overflow bit).
  586.  */
  587.  
  588. #define FS_STAT_OVERFLOW (1 << (sizeof(unsigned int) * 8 - 1))
  589. #define Fs_StatAdd(thisCount, counter, overflow) \
  590.     counter += thisCount; \
  591.     if (counter & FS_STAT_OVERFLOW) { \
  592.         overflow += 1; \
  593.         counter &= ~FS_STAT_OVERFLOW; \
  594.     }
  595.  
  596. /*
  597.  * We've changed things so that heap pages are cacheable.
  598.  * In order to know how much of the vm bytes are found in the cache or not,
  599.  * we need these new counters.  bytesReadForCache now includes heap bytes
  600.  * as does bytesReadForVM, so we use this extra counter to know how much of
  601.  * that is so.
  602.  */
  603.  
  604. extern    Fs_Stats    fs_Stats;
  605.  
  606. #endif _FSSTAT
  607.